package com.ruoyi.project.mahjong.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.mahjong.domain.TShops;
import com.ruoyi.project.mahjong.service.ITShopsService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 店铺Controller
 * 
 * @author ruoyi
 * @date 2023-10-07
 */
@RestController
@RequestMapping("/mahjong/shops")
public class TShopsController extends BaseController
{
    @Autowired
    private ITShopsService tShopsService;

    /**
     * 查询店铺列表
     */
    @PreAuthorize("@ss.hasPermi('mahjong:shops:list')")
    @GetMapping("/list")
    public TableDataInfo list(TShops tShops)
    {
        startPage();
        List<TShops> list = tShopsService.selectTShopsList(tShops);
        return getDataTable(list);
    }

    /**
     * 导出店铺列表
     */
    @PreAuthorize("@ss.hasPermi('mahjong:shops:export')")
    @Log(title = "店铺", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TShops tShops)
    {
        List<TShops> list = tShopsService.selectTShopsList(tShops);
        ExcelUtil<TShops> util = new ExcelUtil<TShops>(TShops.class);
        return util.exportExcel(list, "shops");
    }

    /**
     * 获取店铺详细信息
     */
    @PreAuthorize("@ss.hasPermi('mahjong:shops:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tShopsService.selectTShopsById(id));
    }

    /**
     * 新增店铺
     */
    @PreAuthorize("@ss.hasPermi('mahjong:shops:add')")
    @Log(title = "店铺", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TShops tShops)
    {
        return toAjax(tShopsService.insertTShops(tShops));
    }

    /**
     * 修改店铺
     */
    @PreAuthorize("@ss.hasPermi('mahjong:shops:edit')")
    @Log(title = "店铺", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TShops tShops)
    {
        return toAjax(tShopsService.updateTShops(tShops));
    }

    /**
     * 删除店铺
     */
    @PreAuthorize("@ss.hasPermi('mahjong:shops:remove')")
    @Log(title = "店铺", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tShopsService.deleteTShopsByIds(ids));
    }
}
